package com.sdkj.controller;

import com.sdkj.pojo.Setmeal;
import com.sdkj.service.ConsumerService;
import com.sdkj.util.Result;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
import java.util.Objects;

@RestController
@RequestMapping("/consumer")
public class ConsumerController {

    @Resource
    private ConsumerService consumerService;

    //展示所有套餐
    @RequestMapping("/showSetmealInfo")
    public Result showSetmealInfo(){
        List<Setmeal> list = consumerService.showSetmealInfo();
        return  new Result(true,"",list);
    }

    //展示套餐详情
    @RequestMapping("/showSetmealDetail")
    public Result showSetmealDetail(Integer id){
        Setmeal setmeal = consumerService.showSetmealDetail(id);
        return  new Result(true,"",setmeal);

    }

    // orderInfo数据格式 {"setmealId":12,"orderDate":'2024-10-25',.....}
    //提交预约
    @RequestMapping("/submitOrder")
    public Result submitOrder(@RequestBody Map map){
        Result result = consumerService.submitOrder(map);
        return  result;
    }
    @RequestMapping("/findOrderById")
    public Result findOrderById (Integer id){
        Map<String, Object>map=consumerService.findOrderById(id);
        return new Result(true,"",map);
    }



}
